module.exports = function(sequelize, DataTypes) {
  var Group = sequelize.define('Group', {
    id : {type : DataTypes.INTEGER, primaryKey:true, autoIncrement:true},
    owner_id: {
        type: DataTypes.INTEGER,
        references: "Users",
        referencesKey: 'id'
    },
    title: DataTypes.STRING,
  }, {
    classMethods: {
      associate: function(models) {
        Group.hasMany(models.User, {
          as: 'Member',
          through: 'group_members'
        });
        Group.hasMany(models.Note);
        Group.belongsTo(models.Location); //this needs to be changed to many-to-many later
        Group.belongsTo(models.User, {as:'Owner'});     // Owner of the group
      }
    }
  });

  return Group
}